import psutil

# 检查硬件使用情况脚本

def check_server_resources():
    cpu_usage = psutil.cpu_percent(interval=1)
    memory_info = psutil.virtual_memory()
    disk_usage = psutil.disk_usage('/')

    print(f"CPU使用率: {cpu_usage}%")
    print(f"内存使用率: {memory_info.percent}%")
    print(f"磁盘使用率: {disk_usage.percent}%")

def main():
    check_server_resources()
# python3 check-hardware.py
if __name__ == "__main__":
    main()